import React, { useRef  } from "react";
import { useDispatch } from "react-redux";
import  actionCreators from "@/store/actionCreators/auth";

function Longin() {
  const nameRef = useRef();
  const dispatch = useDispatch();

  const handleSubmit = (e) => {
  
    //阻止
    e.preventDefault();
    const name = nameRef.current.value;
    const user = { name };
    console.log(user,'Longin11');
    dispatch(actionCreators.login(user));
  }
    return (
        <div>
          <form onSubmit={handleSubmit}>
            用户 :<input ref={nameRef}/>
          <input  type="submit"></input>
          </form>
        </div>
      );
}

export default Longin;